A cache memory may store data (e.g., locally where it is instantly accessible to a processor) that replicates data stored in other source memories (e.g., externally where it takes many cycles for a processor to retrieve the data). If a processor requests data and the requested data is stored in the cache (e.g., a “cache hit”), the data may be loaded by simply reading the cache, which is relatively fast. Otherwise, if the requested data is not stored in the cache (e.g., a “cache miss”), the data may be fetched from its original source memory, which is relatively slow. Hence, the more requests that are served from the cache, the faster and more efficient the overall system performance.
To transfer new data into the cache memory, data previously stored in the cache may be erased to make room for the new data. In some cases, a set of data may be used repeatedly by a program or application. In such cases, it may be inefficient to repeatedly load and erase the same data in the cache over and over again for each repeated use. Some current systems implement a lock mechanism to “lock” a set of frequently used data into the cache so that it may not be replaced and may be re-used to avoid redundant data transfer. Typically, an entire line of data is locked together in the cache.
Some systems may lock data after the data has already been loaded in the cache. Such systems typically stall a program, preventing the program from accessing the requested data already loaded into the cache, until the lock is executed. The lock mechanism may search all entries in the cache until the target data is found and locked, which may cause the program to incur an interruption penalty of several computational cycles.
To avoid stalling the program, other systems may lock data in a cache only prior to running the program. The cache memory may be emptied (invalidated) and data may be loaded and locked exclusively into the first available slot(s) of the cache prior to running the program. Although such systems avoid lock interruptions that stall a running program, such systems cannot benefit from the lock mechanism during program operation, thereby using extra computational cycles to re-transfer frequently used data into the cache for each repeated use.
It will be appreciated that for simplicity and clarity of illustration, elements shown in the figures have not necessarily been drawn to scale. For example, the dimensions of some of the elements may be exaggerated relative to other elements for clarity. Further, where considered appropriate, reference numerals may be repeated among the figures to indicate corresponding or analogous elements.